package com.leetcode.LC;

public class LC258 {
    public int addDigits(int num) {

        while (num>=10){
            num=splitNumber(num);
        }
        return num;
    }
    public int splitNumber(int n) {
        int num = 0,sum=0;
        while (n != 0) {
            num = n % 10;
            n /= 10;
            sum+=num;
        }
        return sum;
    }

    public static void main(String[] args) {
        System.out.println(new LC258().addDigits(38));
    }
}
